package com.zzedu.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.core.controller.BaseController;
import com.zzedu.common.core.domain.AjaxResult;
import com.zzedu.common.core.page.TableDataInfo;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.utils.ServletUtils;
import com.zzedu.common.utils.poi.ExcelUtil;
import com.zzedu.domain.ZzStudentLearnReport;
import com.zzedu.dto.ZzStudentLearnReportDTO;
import com.zzedu.service.IZzStudentLearnReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 学生学习报告Controller
 * 
 * @author Mr.Wang
 * @date 2025-07-20
 */
@RestController
@RequestMapping("/school/studentreport")
public class ZzStudentLearnReportController extends BaseController
{
    @Autowired
    private IZzStudentLearnReportService zzStudentLearnReportService;

    /**
     * 查询学生学习报告列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:studentreport:query')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody ZzStudentLearnReportDTO zzStudentLearnReport)
    {
        return getDataTable(zzStudentLearnReportService.page(zzStudentLearnReport.getPageDTO(),zzStudentLearnReportService.buildQuery(zzStudentLearnReport)));
    }

    /**
     * 导出学生学习报告列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:studentreport:export')")
    @Log(title = "学生学习报告", businessType = BusinessType.EXPORT)
    @RequestMapping("/export")
    public void export(ZzStudentLearnReportDTO zzStudentLearnReport)
    {
        List<ZzStudentLearnReport> list = zzStudentLearnReportService.list(zzStudentLearnReportService.buildQuery(zzStudentLearnReport));
        ExcelUtil<ZzStudentLearnReport> util = new ExcelUtil<ZzStudentLearnReport>(ZzStudentLearnReport.class);
        util.exportExcel(ServletUtils.getResponse(),list, "学生学习报告数据");
    }




    /**
     * 新增保存学生学习报告
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:studentreport:add')")
    @Log(title = "学生学习报告", businessType = BusinessType.INSERT)
    @RequestMapping("/add")
    public AjaxResult addSave(@Validated @RequestBody ZzStudentLearnReport zzStudentLearnReport)
    {
        return toAjax(zzStudentLearnReportService.save(zzStudentLearnReport));
    }



    /**
     * 获取学生学习报告详细信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:studentreport:query')")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zzStudentLearnReportService.getById(id));
    }


    /**
     * 修改保存学生学习报告
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:studentreport:edit')")
    @Log(title = "学生学习报告", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    public AjaxResult editSave(@Validated @RequestBody ZzStudentLearnReport zzStudentLearnReport)
    {
        return toAjax(zzStudentLearnReportService.updateById(zzStudentLearnReport));
    }

    /**
     * 删除学生学习报告
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:studentreport:remove')")
    @Log(title = "学生学习报告", businessType = BusinessType.DELETE)
	@RequestMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(zzStudentLearnReportService.removeBatchByIds(ids));
    }
}
